﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using ClassLibrary;

namespace ObTookit
{
    public partial class FormTemplate : Form
    {
        string selectFile = null;

        public FormTemplate()
        {
            InitializeComponent();
        }

        private void FormTemplate_Load(object sender, EventArgs e)
        {
            //InitOpenFileDialog();
        }

        private void InitOpenFileDialog()
        {
            //ofd_template.InitialDirectory = AppDomain.CurrentDomain.BaseDirectory + "Template/";
            //ofd_template.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData, Environment.SpecialFolderOption.None);
            ofd_template.InitialDirectory = Environment.CurrentDirectory + "\\Template\\";
            ofd_template.Filter = "模板文件|*.tpl";
            ofd_template.RestoreDirectory = true;
            ofd_template.FilterIndex = 1;
            ofd_template.Multiselect = false;
            ofd_template.DereferenceLinks = true;
        }

        private void btn_tmp_open_Click(object sender, EventArgs e)
        {
            InitOpenFileDialog();
            DialogResult dr = ofd_template.ShowDialog();
            if (dr == System.Windows.Forms.DialogResult.OK)
            {
                selectFile = ofd_template.FileName;
                bool startNotepad = ProcessUtil.RunProcess("Notepad.exe", selectFile);
                if (!startNotepad)
                {
                    MessageBox.Show("打开记事本程序失败！");
                    return;
                }
                //
                this.tbx_tmp_tip.Text = selectFile;
            }
        }

    }
}
